
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Java8新特性 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../android基础/android零散知识.html" />
    
    
    <link rel="prev" href="数据解析.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../doc/常用网站.html">
            
                <a href="../doc/常用网站.html">
            
                    
                    常用网站
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../常用软件/常用软件和框架.html">
            
                <a href="../常用软件/常用软件和框架.html">
            
                    
                    常用软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../doc/开发规范.html">
            
                <a href="../doc/开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../doc/开源软件.html">
            
                <a href="../doc/开源软件.html">
            
                    
                    开源软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../doc/Android常用代码.html">
            
                <a href="../doc/Android常用代码.html">
            
                    
                    Android常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../源码阅读/源码阅读配置.html">
            
                <a href="../源码阅读/源码阅读配置.html">
            
                    
                    源码阅读
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../源码阅读/其他框架源码.html">
            
                <a href="../源码阅读/其他框架源码.html">
            
                    
                    其他框架源码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../产品经理/产品经理.html">
            
                <a href="../产品经理/产品经理.html">
            
                    
                    产品经理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../设计模式/模式详解.html">
            
                <a href="../设计模式/模式详解.html">
            
                    
                    模式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../设计模式/mvc等.html">
            
                <a href="../设计模式/mvc等.html">
            
                    
                    mvc等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    基本算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    常用数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../常用算法/算法术语.html">
            
                <a href="../常用算法/算法术语.html">
            
                    
                    算法术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../常用算法/排序算法.html">
            
                <a href="../常用算法/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../常用算法/查找算法.html">
            
                <a href="../常用算法/查找算法.html">
            
                    
                    查找算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../常用算法/大数相加.html">
            
                <a href="../常用算法/大数相加.html">
            
                    
                    大数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../常用算法/集合的所有子集.html">
            
                <a href="../常用算法/集合的所有子集.html">
            
                    
                    获得集合的所有子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../常用算法/扫描线种子填充算法.html">
            
                <a href="../常用算法/扫描线种子填充算法.html">
            
                    
                    扫描线种子填充算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../常用算法/其他算法.html">
            
                <a href="../常用算法/其他算法.html">
            
                    
                    其他算法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="原码补码反码.html">
            
                <a href="原码补码反码.html">
            
                    
                    Java部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="原码补码反码.html">
            
                <a href="原码补码反码.html">
            
                    
                    原码补码反码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="java常用代码.html">
            
                <a href="java常用代码.html">
            
                    
                    java常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="JVM详解.html">
            
                <a href="JVM详解.html">
            
                    
                    JVM详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="类加载机制.html">
            
                <a href="类加载机制.html">
            
                    
                    类加载机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="内存模型.html">
            
                <a href="内存模型.html">
            
                    
                    内存模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="GC机制.html">
            
                <a href="GC机制.html">
            
                    
                    GC机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="对象内存布局.html">
            
                <a href="对象内存布局.html">
            
                    
                    对象内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="继承多态.html">
            
                <a href="继承多态.html">
            
                    
                    继承和多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="相等判断.html">
            
                <a href="相等判断.html">
            
                    
                    相等判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="Java容器类.html">
            
                <a href="Java容器类.html">
            
                    
                    Java容器类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="Java枚举.html">
            
                <a href="Java枚举.html">
            
                    
                    Java枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="自定义异常.html">
            
                <a href="自定义异常.html">
            
                    
                    自定义异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="深度拷贝.html">
            
                <a href="深度拷贝.html">
            
                    
                    深度拷贝
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="泛型详解.html">
            
                <a href="泛型详解.html">
            
                    
                    泛型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="线程详解.html">
            
                <a href="线程详解.html">
            
                    
                    线程详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.16" data-path="java注解.html">
            
                <a href="java注解.html">
            
                    
                    注解详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.17" data-path="数据解析.html">
            
                <a href="数据解析.html">
            
                    
                    数据解析
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.11.18" data-path="java8新特性.html">
            
                <a href="java8新特性.html">
            
                    
                    Java8新特性
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../android基础/android零散知识.html">
            
                <a href="../android基础/android零散知识.html">
            
                    
                    Android部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../android基础/基础控件使用.html">
            
                <a href="../android基础/基础控件使用.html">
            
                    
                    基础控件使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../android基础/android零散知识.html">
            
                <a href="../android基础/android零散知识.html">
            
                    
                    Android零散知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../android基础/android坐标体系.html">
            
                <a href="../android基础/android坐标体系.html">
            
                    
                    Android坐标体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../android基础/APP的启动流程.html">
            
                <a href="../android基础/APP的启动流程.html">
            
                    
                    APP启动流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../android基础/View加载流程.html">
            
                <a href="../android基础/View加载流程.html">
            
                    
                    View加载流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../android基础/事件分发机制.html">
            
                <a href="../android基础/事件分发机制.html">
            
                    
                    事件分发机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="../android基础/控件绘制流程.html">
            
                <a href="../android基础/控件绘制流程.html">
            
                    
                    控件绘制流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" data-path="../android基础/常用shape.html">
            
                <a href="../android基础/常用shape.html">
            
                    
                    常用shape
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" data-path="../android基础/进程通信.html">
            
                <a href="../android基础/进程通信.html">
            
                    
                    进程通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" data-path="../通信方式/通信方式详解.html">
            
                <a href="../通信方式/通信方式详解.html">
            
                    
                    通信方式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" data-path="../android基础/Binder详解.html">
            
                <a href="../android基础/Binder详解.html">
            
                    
                    Binder详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.12" data-path="../android基础/Handler详解.html">
            
                <a href="../android基础/Handler详解.html">
            
                    
                    Handle详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.13" data-path="../android基础/Fragment详解.html">
            
                <a href="../android基础/Fragment详解.html">
            
                    
                    Fragment详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.14" data-path="../android基础/Activity详解.html">
            
                <a href="../android基础/Activity详解.html">
            
                    
                    Activity详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.15" data-path="../android基础/BroadcastReceiver.html">
            
                <a href="../android基础/BroadcastReceiver.html">
            
                    
                    BroadcastReceiver详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.16" data-path="../android基础/Service服务.html">
            
                <a href="../android基础/Service服务.html">
            
                    
                    Service详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.17" data-path="../android基础/动画详解.html">
            
                <a href="../android基础/动画详解.html">
            
                    
                    动画详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.18" data-path="../android基础/屏幕刷新机制.html">
            
                <a href="../android基础/屏幕刷新机制.html">
            
                    
                    屏幕刷新机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.19" data-path="../android基础/屏幕适配.html">
            
                <a href="../android基础/屏幕适配.html">
            
                    
                    屏幕适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.20" data-path="../android基础/图片加载详解.html">
            
                <a href="../android基础/图片加载详解.html">
            
                    
                    图片加载详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.21" data-path="../android基础/WebView详解.html">
            
                <a href="../android基础/WebView详解.html">
            
                    
                    WebView详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.22" data-path="../android基础/沉浸式.html">
            
                <a href="../android基础/沉浸式.html">
            
                    
                    沉浸式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.23" data-path="../android基础/相机模块.html">
            
                <a href="../android基础/相机模块.html">
            
                    
                    相机模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.24" data-path="../android基础/地图模块.html">
            
                <a href="../android基础/地图模块.html">
            
                    
                    地图模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.25" data-path="../android基础/Androidstudio插件开发.html">
            
                <a href="../android基础/Androidstudio插件开发.html">
            
                    
                    Androidstudio插件开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.26" data-path="../android基础/Apk插件化开发.html">
            
                <a href="../android基础/Apk插件化开发.html">
            
                    
                    Apk插件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.27" data-path="../android基础/App组件化开发.html">
            
                <a href="../android基础/App组件化开发.html">
            
                    
                    App组件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.28" data-path="../android基础/sdk开发.html">
            
                <a href="../android基础/sdk开发.html">
            
                    
                    sdk开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.29" data-path="../android基础/APP优化.html">
            
                <a href="../android基础/APP优化.html">
            
                    
                    APP优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.30" data-path="../android基础/项目参数配置.html">
            
                <a href="../android基础/项目参数配置.html">
            
                    
                    项目参数配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.31" data-path="../android基础/App发布.html">
            
                <a href="../android基础/App发布.html">
            
                    
                    App发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.32" data-path="../android基础/Android外挂.html">
            
                <a href="../android基础/Android外挂.html">
            
                    
                    Android外挂
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.33" data-path="../android基础/Android字节码插桩.html">
            
                <a href="../android基础/Android字节码插桩.html">
            
                    
                    Android字节码插桩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.34" data-path="../android基础/智能家居.html">
            
                <a href="../android基础/智能家居.html">
            
                    
                    智能家居
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../python/python爬虫.html">
            
                <a href="../python/python爬虫.html">
            
                    
                    python爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../gradle/Groovy.html">
            
                <a href="../gradle/Groovy.html">
            
                    
                    Groovy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../kotlin/kotlin部分.html">
            
                <a href="../kotlin/kotlin部分.html">
            
                    
                    kotlin部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../flutter/flutter部分.html">
            
                <a href="../flutter/flutter部分.html">
            
                    
                    flutter部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    native部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../native/Linux.html">
            
                <a href="../native/Linux.html">
            
                    
                    Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    cCpp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../native/NDK.html">
            
                <a href="../native/NDK.html">
            
                    
                    NDK
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../native/系统编译剪裁.html">
            
                <a href="../native/系统编译剪裁.html">
            
                    
                    系统编译剪裁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.5" data-path="../native/音视频.html">
            
                <a href="../native/音视频.html">
            
                    
                    音视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.6" data-path="../native/音视频第三方库.html">
            
                <a href="../native/音视频第三方库.html">
            
                    
                    音视频第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.7" data-path="../native/相关代码.html">
            
                <a href="../native/相关代码.html">
            
                    
                    相关代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../server/服务器部分.html">
            
                <a href="../server/服务器部分.html">
            
                    
                    服务器部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../webDev/web部分.html">
            
                <a href="../webDev/web部分.html">
            
                    
                    web部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../人工智能/人工智能相关概念.html">
            
                <a href="../人工智能/人工智能相关概念.html">
            
                    
                    人工智能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../面试真题/极飞.html">
            
                <a href="../面试真题/极飞.html">
            
                    
                    面试真题
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Java8新特性</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#java8&#x65B0;&#x7279;&#x6027;"><b>1. </b>java8&#x65B0;&#x7279;&#x6027;</a></li><ul><li><span class="title-icon "></span><a href="#java-lambda"><b>1.1. </b>Java Lambda</a></li><li><span class="title-icon "></span><a href="#&#x65B9;&#x6CD5;&#x5F15;&#x7528;"><b>1.2. </b>&#x65B9;&#x6CD5;&#x5F15;&#x7528;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5F15;&#x7528;&#x5206;&#x7C7B;"><b>1.2.1. </b>&#x5F15;&#x7528;&#x5206;&#x7C7B;</a></li></ul><li><span class="title-icon "></span><a href="#&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;-functional-interface"><b>1.3. </b>&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3; Functional Interface</a></li><ul><li><span class="title-icon "></span><a href="#&#x5185;&#x7F6E;&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;"><b>1.3.1. </b>&#x5185;&#x7F6E;&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;</a></li></ul><li><span class="title-icon "></span><a href="#&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;-functional-programming"><b>1.4. </b>&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B; functional programming</a></li><li><span class="title-icon "></span><a href="#&#x4E3A;&#x4EC0;&#x4E48;-&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;-&#x53C8;&#x88AB;&#x5927;&#x91CF;&#x91C7;&#x7528;&#x548C;&#x652F;&#x6301;"><b>1.5. </b>&#x4E3A;&#x4EC0;&#x4E48; &#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B; &#x53C8;&#x88AB;&#x5927;&#x91CF;&#x91C7;&#x7528;&#x548C;&#x652F;&#x6301;</a></li><li><span class="title-icon "></span><a href="#&#x533F;&#x540D;&#x51FD;&#x6570;"><b>1.6. </b>&#x533F;&#x540D;&#x51FD;&#x6570;</a></li><li><span class="title-icon "></span><a href="#optional"><b>1.7. </b>Optional</a></li><li><span class="title-icon "></span><a href="#stream"><b>1.8. </b>Stream</a></li><li><span class="title-icon "></span><a href="#stream-&#x5EF6;&#x8FDF;&#x6267;&#x884C;"><b>1.9. </b>Stream &#x5EF6;&#x8FDF;&#x6267;&#x884C;</a></li><li><span class="title-icon "></span><a href="#&#x65E5;&#x671F;&#x65F6;&#x95F4;-api"><b>1.10. </b>&#x65E5;&#x671F;&#x65F6;&#x95F4; API</a></li><li><span class="title-icon "></span><a href="#&#x91CD;&#x590D;&#x6CE8;&#x89E3;"><b>1.11. </b>&#x91CD;&#x590D;&#x6CE8;&#x89E3;</a></li></ul></ul></div><a href="#java8&#x65B0;&#x7279;&#x6027;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="java8&#x65B0;&#x7279;&#x6027;"><a name="java8&#x65B0;&#x7279;&#x6027;" class="anchor-navigation-ex-anchor" href="#java8&#x65B0;&#x7279;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>1. java8&#x65B0;&#x7279;&#x6027;</h1>
<table>
<thead>
<tr>
<th>java8&#x65B0;&#x7279;&#x6027;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>1&#x3001;Lambda&#x8868;&#x8FBE;&#x5F0F;</td>
<td>-</td>
</tr>
<tr>
<td>2&#x3001;&#x63A5;&#x53E3;&#x7684;&#x9ED8;&#x8BA4;&#x65B9;&#x6CD5;&#x4E0E;&#x9759;&#x6001;&#x65B9;&#x6CD5;</td>
<td>-</td>
</tr>
<tr>
<td>3&#x3001;&#x65B9;&#x6CD5;&#x5F15;&#x7528;</td>
<td>-</td>
</tr>
<tr>
<td>4&#x3001;&#x91CD;&#x590D;&#x6CE8;&#x89E3;</td>
<td>-</td>
</tr>
<tr>
<td>5&#x3001;&#x6269;&#x5C55;&#x6CE8;&#x89E3;&#x7684;&#x652F;&#x6301;</td>
<td></td>
</tr>
<tr>
<td>6&#x3001;Optional</td>
<td>-</td>
</tr>
<tr>
<td>7&#x3001;Stream</td>
<td>-</td>
</tr>
<tr>
<td>8&#x3001;Date/Time API (JSR 310)</td>
<td>-</td>
</tr>
<tr>
<td>9&#x3001;JavaScript&#x5F15;&#x64CE;Nashorn</td>
<td></td>
</tr>
<tr>
<td>10&#x3001;Base64</td>
<td>java8&#x5BF9;Base64&#x8FDB;&#x884C;&#x4F18;&#x5316;&#x540E;&#xFF0C;&#x653E;&#x5230;java.util&#x5305;&#x4E0B;</td>
</tr>
</tbody>
</table>
<h2 id="java-lambda"><a name="java-lambda" class="anchor-navigation-ex-anchor" href="#java-lambda"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. Java Lambda</h2>
<p>Lambda&#x662F;Java8&#x7684;&#x65B0;&#x7279;&#x6027; &#xFF0C;&#x662F;&#x4E00;&#x4E2A;&#x8BED;&#x6CD5;&#x7CD6;</p>
<pre><code class="lang-text">// &#x8BED;&#x6CD5;&#x683C;&#x5F0F;
(params) -&gt; expression
(params) -&gt; statement
(params) -&gt;{ statements; }

// List&#x5FAA;&#x73AF;
List&lt;String&gt; list = ...;
list.forEach( reslut -&gt; {
    reslut +=&quot;_&#x4FEE;&#x6539;&#x8FC7;&quot; ;
});
// &#x5FAA;&#x73AF;&#x8F93;&#x51FA;
list.forEach(System.out::println);

//Map&#x5FAA;&#x73AF;
Map&lt;String, Integer&gt; map =...;
map.forEach( (key ,value)-&gt; {
    value +=100 ;
});
map.forEach( ( key ,value ) -&gt; System.out.println( &quot;key=&quot;+key +&quot;  value=&quot;+value)  );

// List &#x6761;&#x4EF6;&#x8FC7;&#x6EE4;
List&lt;String&gt; result1 =
        // &#x5C06;list&#x8F6C;&#x4E3A; &#x6D41;
        list.stream()
        // &#x5C06;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x7684;&#x5143;&#x7D20;&#x8FC7;&#x6EE4;&#x51FA;&#x6765;
        .filter( line -&gt; line.contains(&quot;aa&quot;))
        // &#x6536;&#x96C6;&#x5E76;&#x5C06;&#x8F93;&#x51FA;&#x7684;&#x6D41;&#x8F6C;&#x4E3A; list
        .collect(Collectors.toList());
result1.forEach(System.out::println);

// &#x5BF9;&#x8C61;&#x6392;&#x5E8F;
List&lt;Student&gt; listSort= ... ;
listSort.sort( (Student stu1 , Student stu2) -&gt; stu1.age- stu2.age);
listSort.forEach( (sutdent) -&gt; {
    System.out.println(sutdent.name+&quot; : &quot;+sutdent.age);
});
</code></pre>
<h4 id="&#x63A5;&#x53E3;&#x7684;&#x9ED8;&#x8BA4;&#x65B9;&#x6CD5;&#x4E0E;&#x9759;&#x6001;&#x65B9;&#x6CD5;"><a name="&#x63A5;&#x53E3;&#x7684;&#x9ED8;&#x8BA4;&#x65B9;&#x6CD5;&#x4E0E;&#x9759;&#x6001;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x63A5;&#x53E3;&#x7684;&#x9ED8;&#x8BA4;&#x65B9;&#x6CD5;&#x4E0E;&#x9759;&#x6001;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x63A5;&#x53E3;&#x7684;&#x9ED8;&#x8BA4;&#x65B9;&#x6CD5;&#x4E0E;&#x9759;&#x6001;&#x65B9;&#x6CD5;</h4>
<pre><code class="lang-text">public interface MyMathTool {
    // &#x88AB; default&#x5173;&#x952E;&#x5B57; &#x4FEE;&#x9970;&#x8FC7;&#x7684; sqrt &#x65B9;&#x6CD5; &#x5C06;&#x5728;&#x5B50;&#x7C7B;&#x4E0A;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;.
    // &#x53EF;&#x4EE5;&#x6709;&#x591A;&#x4E2A; &#x9ED8;&#x8BA4;&#x65B9;&#x6CD5;
    default double sqrt(int a) {
        return Math.sqrt(a);
    }
}

// &#x88AB; static&#x4FEE;&#x9970;&#x7684;&#x65B9;&#x6CD5; &#xFF0C;&#x8DDF;&#x666E;&#x901A;&#x7C7B;&#x7684;&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x4E00;&#x6837;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x8C03;&#x7528;
// &#x53EF;&#x4EE5;&#x6709;&#x591A;&#x4E2A; &#x9759;&#x6001;&#x65B9;&#x6CD5;
static double cacle(int a, int b){
    return  a+b ;
}
</code></pre>
<h2 id="&#x65B9;&#x6CD5;&#x5F15;&#x7528;"><a name="&#x65B9;&#x6CD5;&#x5F15;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x65B9;&#x6CD5;&#x5F15;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. &#x65B9;&#x6CD5;&#x5F15;&#x7528;</h2>
<pre><code class="lang-text">&#x65B9;&#x6CD5;&#x5F15;&#x7528;&#x662F; lambda &#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x4E00;&#x79CD;&#x8BED;&#x6CD5;&#x7CD6;, &#x4E3A;&#x4E86;&#x7B80;&#x5316;&#x4EE3;&#x7801;&#x548C;&#x52A0;&#x901F;&#x5F00;&#x53D1;&#x3002;

&#x5F53;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#x7684;&#x90A3;&#x4E2A;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#xFF0C;&#x4F46;&#x662F;&#x5DF2;&#x7ECF;&#x6709;&#x7C7B;&#x5B9E;&#x73B0;&#x4E86;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x7684;&#x529F;&#x80FD;&#xFF0C;
&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x7528;&#x65B9;&#x6CD5;&#x5F15;&#x7528;&#x6765;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x73B0;&#x6709;&#x7C7B;&#x7684;&#x529F;&#x80FD;&#x53BB;&#x5B9E;&#x73B0;&#x3002;&#xFF08;&#x81F3;&#x4E8E;&#x4E3A;&#x4EC0;&#x4E48;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#xFF0C;&#x6211;&#x6682;&#x65F6;&#x8FD8;&#x4E0D;&#x77E5;&#x9053;&#xFF0C;&#x6CA1;&#x770B;&#x6E90;&#x7801;&#x3002;&#xFF09;

&#x65B9;&#x6CD5;&#x5F15;&#x7528;&#x89C4;&#x5B9A;&#xFF1A;&#x5B9E;&#x73B0;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x5217;&#x8868;&#xFF0C;&#x5FC5;&#x987B;&#x4E0E;&#x65B9;&#x6CD5;&#x5F15;&#x7528;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x5217;&#x8868;&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#x3002;&#x8FD4;&#x56DE;&#x503C;&#x5C31;&#x4E0D;&#x4F5C;&#x8981;&#x6C42;&#x3002;
</code></pre>
<h3 id="&#x5F15;&#x7528;&#x5206;&#x7C7B;"><a name="&#x5F15;&#x7528;&#x5206;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#&#x5F15;&#x7528;&#x5206;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.1. &#x5F15;&#x7528;&#x5206;&#x7C7B;</h3>
<table>
<thead>
<tr>
<th>&#x5206;&#x7C7B;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x5F15;&#x7528;&#x65B9;&#x6CD5;</td>
<td>&#x7C7B;&#x540D;::&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x540D;<br> &#x7C7B;&#x540D;::&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x540D; <br> &#x5B9E;&#x4F8B;::&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x540D;</td>
</tr>
<tr>
<td>&#x5F15;&#x7528;&#x6784;&#x9020;&#x5668;</td>
<td></td>
</tr>
<tr>
<td>&#x5F15;&#x7528;&#x6570;&#x7EC4;</td>
<td></td>
</tr>
</tbody>
</table>
<pre><code class="lang-text">// &#x5B9E;&#x4F8B;::&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x540D;
Consumer&lt;String&gt; consumer = System.out::println;
consumer.accept(&quot;This is Major Tom&quot;);

// &#x7C7B;&#x540D;::&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x540D;
Function&lt;Long, Long&gt; f = Math::abs;
Long result = f.apply(-3L);

// &#x7C7B;&#x540D;::&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x540D;
// &#x8FD9;&#x4E2A;&#x5730;&#x65B9;&#x6709;&#x70B9;&#x4E0D;&#x592A;&#x597D;&#x7406;&#x89E3;&#x3002;
// &#x53EF;&#x4EE5;&#x6682;&#x65F6;&#x8FD9;&#x6837;&#x7406;&#x89E3;&#xFF1A; &#x751F;&#x6210;&#x4E86;&#x4E00;&#x4E2A; BiPredicate &#x5B9E;&#x4F8B;b &#xFF0C;
// &#x5E76;&#x4E14; b&#x4E2D;&#x7684; &#x65B9;&#x6CD5; test&#x91CC;&#x9762;&#x7684;&#x5185;&#x5BB9;&#x548C; String&#x7C7B;&#x7684;&#x9759;&#x6001;&#x65B9;&#x6CD5; equals &#x4E00;&#x6A21;&#x4E00;&#x6837;
BiPredicate&lt;String, String&gt; b = String::equals;
b.test(&quot;abc&quot;, &quot;abcd&quot;);

// &#x5F15;&#x7528;&#x6784;&#x9020;&#x5668;
Function&lt;Integer, StringBuffer&gt; fun = StringBuffer::new;
StringBuffer buffer = fun.apply(10);

//  &#x5F15;&#x7528;&#x6570;&#x7EC4;
Function&lt;Integer, Integer[]&gt; fun2 = Integer[]::new;
Integer[] arr2 = fun2.apply(10);
</code></pre>
<h2 id="&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;-functional-interface"><a name="&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;-functional-interface" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;-functional-interface"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. &#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3; Functional Interface</h2>
<p>&#x4E3A;&#x4E86;&#x66F4;&#x53CB;&#x597D;&#x7684;&#x652F;&#x6301; Lambda &#x8868;&#x8FBE;&#x5F0F;&#xFF0C;Java 8&#x5F15;&#x5165;&#x4E86;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#x7684;&#x6982;&#x5FF5;&#x3002;
&#x6240;&#x8C13;&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#xFF0C;&#x5C31;&#x662F;&#x662F;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#xFF0C;&#x8FD9;&#x4E2A;&#x63A5;&#x53E3;&#x53EA;&#x80FD;&#x6709;&#x4E00;&#x4E2A; &#x62BD;&#x8C61;&#x65B9;&#x6CD5; &#x3002;</p>
<pre><code class="lang-text">1&#x3001;Java 8&#x4E3A;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#x5F15;&#x5165;&#x4E86;&#x4E00;&#x4E2A;&#x65B0;&#x6CE8;&#x89E3; @FunctionalInterface&#xFF0C;&#x4E3B;&#x8981;&#x7528;&#x4E8E;&#x7F16;&#x8BD1;&#x7EA7;&#x9519;&#x8BEF;&#x68C0;&#x67E5;&#xFF0C;
&#x52A0;&#x4E0A;&#x8BE5;&#x6CE8;&#x89E3;&#xFF0C;&#x5F53;&#x4F60;&#x5199;&#x7684;&#x63A5;&#x53E3;&#x4E0D;&#x7B26;&#x5408;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x7F16;&#x8BD1;&#x5668;&#x4F1A;&#x62A5;&#x9519;&#x3002;

2&#x3001;&#x52A0;&#x4E0D;&#x52A0;@FunctionalInterface&#x5BF9;&#x4E8E;&#x63A5;&#x53E3;&#x662F;&#x4E0D;&#x662F;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#x6CA1;&#x6709;&#x5F71;&#x54CD;&#xFF0C;
&#x8BE5;&#x6CE8;&#x89E3;&#x53EA;&#x662F;&#x63D0;&#x9192;&#x7F16;&#x8BD1;&#x5668;&#x53BB;&#x68C0;&#x67E5;&#x8BE5;&#x63A5;&#x53E3;&#x662F;&#x5426;&#x4EC5;&#x5305;&#x542B;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;

3&#x3001;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#x91CC;&#x662F;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x9ED8;&#x8BA4;&#x65B9;&#x6CD5; &#x3001;&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x3001;Object&#x91CC;&#x7684;public&#x65B9;&#x6CD5;

&#x5F53;&#x4E00;&#x4E2A;&#x7C7B;&#x662F;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;Lambda&#x8868;&#x8FBE;&#x5F0F;&#x6765;&#x5B9E;&#x4F8B;&#x5316;&#x5B83;&#xFF0C;
&#x800C;&#x4E0D;&#x7528;&#x5199;&#x5F88;&#x591A;&#x6A21;&#x677F;&#x5F0F;&#x4EE3;&#x7801;&#x3002; 
@FunctionalInterface
public interface Consumer {
    void accept(String msg);
}

// &#x4F20;&#x7EDF; &#x547D;&#x4EE4;&#x5F0F;&#x3001;&#x9762;&#x5411;&#x5BF9;&#x8C61; &#x7F16;&#x7A0B;
Consumer consumer = new Consumer() {
    @Override
    public void accept(String msg) {   }
};
// Lambda &#x8868;&#x8FBE;&#x5F0F;&#x5199;&#x6CD5; &#x66F4;&#x7B80;&#x6D01;
Consumer consumer2 = (String msg) -&gt; { } ;
</code></pre>
<h3 id="&#x5185;&#x7F6E;&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;"><a name="&#x5185;&#x7F6E;&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;" class="anchor-navigation-ex-anchor" href="#&#x5185;&#x7F6E;&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1. &#x5185;&#x7F6E;&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;</h3>
<p>&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x5F00;&#x53D1;&#x8005;&#xFF0C;java8&#x5185;&#x7F6E;&#x4E86;&#x4E00;&#x6279;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;&#x3002;</p>
<table>
<thead>
<tr>
<th>Java8&#x5185;&#x7F6E;&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x63A5;&#x53E3;</th>
<th>&#x53C2;&#x6570;&#x7C7B;&#x578B;</th>
<th>&#x8FD4;&#x56DE;&#x7C7B;&#x578B;</th>
<th>&#x7528;&#x9014;</th>
</tr>
</thead>
<tbody>
<tr>
<td>Consumer</td>
<td>T</td>
<td>void</td>
<td>&#x5BF9;&#x7C7B;&#x578B;T&#x53C2;&#x6570;&#x64CD;&#x4F5C;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#xFF0C;&#x5305;&#x542B;&#x65B9;&#x6CD5; void accept(T t)</td>
</tr>
<tr>
<td>Supplier</td>
<td>&#x65E0;</td>
<td>T</td>
<td>&#x8FD4;&#x56DE;T&#x7C7B;&#x578B;&#x53C2;&#x6570;&#xFF0C;&#x65B9;&#x6CD5;&#x65F6; T get()</td>
</tr>
<tr>
<td>Function<t,r></t,r></td>
<td>T</td>
<td>R</td>
<td>&#x5BF9;&#x7C7B;&#x578B;T&#x53C2;&#x6570;&#x64CD;&#x4F5C;&#xFF0C;&#x8FD4;&#x56DE;R&#x7C7B;&#x578B;&#x53C2;&#x6570;&#xFF0C;&#x5305;&#x542B;&#x65B9;&#x6CD5; R apply&#xFF08;T t&#xFF09;</td>
</tr>
<tr>
<td>Predicate</td>
<td>T</td>
<td>boolean</td>
<td>&#x65AD;&#x8A00;&#x578B;&#x63A5;&#x53E3;&#xFF0C;&#x5BF9;&#x7C7B;&#x578B;T&#x8FDB;&#x884C;&#x6761;&#x4EF6;&#x7B5B;&#x9009;&#x64CD;&#x4F5C;&#xFF0C;&#x8FD4;&#x56DE;boolean&#xFF0C;&#x5305;&#x542B;&#x65B9;&#x6CD5; boolean test&#xFF08;T t&#xFF09;</td>
</tr>
<tr>
<td>BinaryOperator</td>
<td>T,T</td>
<td>T</td>
<td>&#x5BF9;&#x7C7B;&#x578B;T&#x5BF9;&#x8C61;&#x8FDB;&#x884C;&#x4E8C;&#x5143;&#x8FD0;&#x7B97;&#xFF0C;&#x5E76;&#x8FD4;&#x56DE;T&#x7C7B;&#x578B;&#x7684;&#x7ED3;&#x679C;&#xFF0C;&#x5305;&#x542B;&#x65B9;&#x6CD5;T apply(T t1,T t2)</td>
</tr>
<tr>
<td>BigConsumer</td>
<td>T,U</td>
<td>void</td>
<td>&#x5BF9;&#x7C7B;&#x578B;T&#xFF0C;u&#x53C2;&#x6570;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;&#xFF0C;&#x5305;&#x542B;&#x65B9;&#x6CD5;void accept&#xFF08;T t,U u&#xFF09;</td>
</tr>
<tr>
<td>BiConsumer<t,u></t,u></td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E86;&#x4E00;&#x4E2A;&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5E76;&#x4E14;&#x4E0D;&#x8FD4;&#x56DE;&#x4EFB;&#x4F55;&#x7ED3;&#x679C;</td>
</tr>
<tr>
<td>BiFunction<t,u,r></t,u,r></td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E86;&#x4E00;&#x4E2A;&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x5E76;&#x4E14;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7ED3;&#x679C;</td>
</tr>
<tr>
<td>BinaryOperator<t></t></td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E86;&#x4E00;&#x4E2A;&#x4F5C;&#x7528;&#x4E8E;&#x4E8E;&#x4E24;&#x4E2A;&#x540C;&#x7C7B;&#x578B;&#x64CD;&#x4F5C;&#x7B26;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5E76;&#x4E14;&#x8FD4;&#x56DE;&#x4E86;&#x64CD;&#x4F5C;&#x7B26;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x7ED3;&#x679C;</td>
</tr>
<tr>
<td>BiPredicate<t,u></t,u></td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E86;&#x4E00;&#x4E2A;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x7684;boolean&#x503C;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>BooleanSupplier</td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E86;boolean&#x503C;&#x7ED3;&#x679C;&#x7684;&#x63D0;&#x4F9B;&#x65B9;</td>
</tr>
<tr>
<td>Consumer<t></t></td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E86;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x5E76;&#x4E14;&#x65E0;&#x8FD4;&#x56DE;&#x7684;&#x64CD;&#x4F5C;</td>
</tr>
<tr>
<td>DoubleBinaryOperator</td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E86;&#x4F5C;&#x7528;&#x4E8E;&#x4E24;&#x4E2A;double&#x503C;&#x64CD;&#x4F5C;&#x7B26;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5E76;&#x4E14;&#x8FD4;&#x56DE;&#x4E86;&#x4E00;&#x4E2A;double&#x503C;&#x7684;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>DoubleConsumer</td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E00;&#x4E2A;&#x63A5;&#x53D7;double&#x503C;&#x53C2;&#x6570;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5E76;&#x4E14;&#x4E0D;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>DoubleFunction<r></r></td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;double&#x503C;&#x53C2;&#x6570;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x5E76;&#x4E14;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;</td>
</tr>
<tr>
<td>DoublePredicate</td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E00;&#x4E2A;&#x62E5;&#x6709;double&#x503C;&#x53C2;&#x6570;&#x7684;boolean&#x503C;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>DoubleSupplier</td>
<td></td>
<td></td>
<td>&#x4EE3;&#x8868;&#x4E00;&#x4E2A;double&#x503C;&#x7ED3;&#x6784;&#x7684;&#x63D0;&#x4F9B;&#x65B9;</td>
</tr>
<tr>
<td>DoubleToIntFunction</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x8F93;&#x5165;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>DoubleToLongFunction</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x8F93;&#x5165;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x7ED3;&#x679C;</td>
</tr>
<tr>
<td>DoubleUnaryOperator</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x540C;&#x4E3A;&#x7C7B;&#x578B;double,&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E5F;&#x4E3A;double &#x3002;</td>
</tr>
<tr>
<td>IntBinaryOperator</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x540C;&#x4E3A;&#x7C7B;&#x578B;int,&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E5F;&#x4E3A;int &#x3002;</td>
</tr>
<tr>
<td>IntConsumer</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x7684;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C; &#x3002;</td>
</tr>
<tr>
<td>IntFunction<r></r></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7ED3;&#x679C; &#x3002;</td>
</tr>
<tr>
<td>IntPredicate</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;int&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x503C;&#x7684;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>IntSupplier</td>
<td></td>
<td></td>
<td>&#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>IntToDoubleFunction</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x8F93;&#x5165;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x7ED3;&#x679C; &#x3002;</td>
</tr>
<tr>
<td>IntToLongFunction</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x8F93;&#x5165;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>IntUnaryOperator</td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x540C;&#x4E3A;&#x7C7B;&#x578B;int,&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E5F;&#x4E3A;int &#x3002;</td>
</tr>
<tr>
<td>LongBinaryOperator</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x540C;&#x4E3A;&#x7C7B;&#x578B;long,&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E5F;&#x4E3A;long&#x3002;</td>
</tr>
<tr>
<td>LongConsumer</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x7684;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;&#x3002;</td>
</tr>
<tr>
<td>LongFunction<r></r></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>LongPredicate</td>
<td></td>
<td></td>
<td>R&#x63A5;&#x53D7;&#x4E00;&#x4E2A;long&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x503C;&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>LongSupplier</td>
<td></td>
<td></td>
<td>&#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7ED3;&#x679C;long&#x7C7B;&#x578B;&#x7684;&#x503C;&#x3002;</td>
</tr>
<tr>
<td>LongToDoubleFunction</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x8F93;&#x5165;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>LongToIntFunction</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x8F93;&#x5165;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>LongUnaryOperator</td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x540C;&#x4E3A;&#x7C7B;&#x578B;long,&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E5F;&#x4E3A;long&#x3002;</td>
</tr>
<tr>
<td>ObjDoubleConsumer<t></t></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;object&#x7C7B;&#x578B;&#x548C;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x7684;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;&#x3002;</td>
</tr>
<tr>
<td>ObjIntConsumer<t></t></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;object&#x7C7B;&#x578B;&#x548C;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x7684;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;&#x3002;</td>
</tr>
<tr>
<td>ObjLongConsumer<t></t></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;object&#x7C7B;&#x578B;&#x548C;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x7684;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;&#x3002;</td>
</tr>
<tr>
<td>Predicate<t></t></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x503C;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>Supplier<t></t></td>
<td></td>
<td></td>
<td>&#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>ToDoubleBiFunction<t,u></t,u></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x7ED3;&#x679C;</td>
</tr>
<tr>
<td>ToDoubleFunction<t></t></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;double&#x7C7B;&#x578B;&#x7ED3;&#x679C;</td>
</tr>
<tr>
<td>ToIntBiFunction<t,u></t,u></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>ToIntFunction<t></t></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;int&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>ToLongBiFunction<t,u></t,u></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>ToLongFunction<t></t></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;long&#x7C7B;&#x578B;&#x7ED3;&#x679C;&#x3002;</td>
</tr>
<tr>
<td>UnaryOperator<t></t></td>
<td></td>
<td></td>
<td>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x7C7B;&#x578B;T,&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E5F;&#x4E3A;T&#x3002;</td>
</tr>
</tbody>
</table>
<h2 id="&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;-functional-programming"><a name="&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;-functional-programming" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;-functional-programming"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. &#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B; functional programming</h2>
<pre><code class="lang-text">&#x547D;&#x4EE4;&#x5F0F; &#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#x5305;&#x62EC; &#x8FC7;&#x7A0B;&#x5F0F;&#x7F16;&#x7A0B; &#x548C; &#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7F16;&#x7A0B;(OOP) &#x3002;
&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;( FP ) &#x662F;&#x4E00;&#x79CD; &#x7F16;&#x7A0B;&#x8303;&#x5F0F; &#xFF0C;&#x662F;&#x4E00;&#x79CD;&#x7F16;&#x7A0B;&#x601D;&#x60F3;&#x3002;

// &#x547D;&#x4EE4;&#x5F0F;&#x7F16;&#x7A0B; 
&#x66F4;&#x52A0;&#x6CE8;&#x91CD; &#x201C;&#x5982;&#x4F55;&#x505A;&#x201D;&#xFF0C;&#x4E3B;&#x8981;&#x601D;&#x60F3;&#x662F;&#x5173;&#x6CE8;&#x8BA1;&#x7B97;&#x673A;&#x6267;&#x884C;&#x7684;&#x6B65;&#x9AA4;&#xFF0C;&#x5373;&#x4E00;&#x6B65;&#x4E00;&#x6B65;&#x544A;&#x8BC9;&#x8BA1;&#x7B97;&#x673A;&#x5148;&#x505A;&#x4EC0;&#x4E48;&#x518D;&#x505A;&#x4EC0;&#x4E48;&#x3002;
//  &#x58F0;&#x660E;&#x5F0F;&#x7F16;&#x7A0B;
&#x4E3B;&#x8981;&#x601D;&#x60F3;&#x662F;&#x544A;&#x8BC9;&#x8BA1;&#x7B97;&#x673A;&#x5E94;&#x8BE5;&#x505A;&#x4EC0;&#x4E48;&#xFF0C;&#x4F46;&#x4E0D;&#x6307;&#x5B9A;&#x5177;&#x4F53;&#x8981;&#x600E;&#x4E48;&#x505A;&#xFF0C;SQL&#x8BED;&#x53E5;&#x5C31;&#x662F;&#x6700;&#x660E;&#x663E;&#x7684;&#x4E00;&#x79CD;&#x58F0;&#x660E;&#x5F0F;&#x7F16;&#x7A0B;&#x7684;&#x4F8B;&#x5B50;&#x3002;
//&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;  
&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;&#x548C;&#x58F0;&#x660E;&#x5F0F;&#x7F16;&#x7A0B;&#x662F;&#x6709;&#x6240;&#x5173;&#x8054;&#x7684;&#xFF0C;&#x4ED6;&#x4EEC;&#x90FD;&#x53EA;&#x5173;&#x6CE8;&#x505A;&#x4EC0;&#x4E48;&#x800C;&#x4E0D;&#x662F;&#x600E;&#x4E48;&#x505A;&#x3002;
&#x4F46;&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;&#x4E0D;&#x4EC5;&#x4EC5;&#x5C40;&#x9650;&#x4E8E;&#x58F0;&#x660E;&#x5F0F;&#x7F16;&#x7A0B;&#x3002;
OOP &#x5173;&#x6CE8;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#x7684;&#x8C03;&#x7528;&#xFF0C;&#x800C; FP&#x5173;&#x6CE8;&#x51FD;&#x6570;&#x4E4B;&#x95F4;&#x7684;&#x8C03;&#x7528;&#x3002;

// &#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;&#x7684;&#x7279;&#x70B9;
1&#x3001;&#x51FD;&#x6570;&#x662F;&#x4E00;&#x7B49;&#x516C;&#x6C11;&#x3002;&#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x4F5C;&#x4E3A;&#x53C2;&#x6570; &#x4E5F;&#x53EF;&#x4EE5;&#x4F5C;&#x4E3A;&#x8FD4;&#x56DE;&#x503C;&#x3002;
&#x51FD;&#x6570;&#x4E0E;&#x5176;&#x4ED6;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x4E00;&#x6837;&#xFF0C;&#x5904;&#x4E8E;&#x5E73;&#x7B49;&#x5730;&#x4F4D;&#x3002;
var print = function(i){ console.log(i);};
[1,2,3].forEach(print); // print &#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x53EF;&#x4EE5;&#x4F5C;&#x4E3A;&#x53E6;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570;&#x3002;

2&#x3001;&#x65E0;&#x526F;&#x4F5C;&#x7528;&#x3002;
&#x6240;&#x6709;&#x529F;&#x80FD;&#x5C31;&#x662F;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x503C;&#xFF0C;&#x6CA1;&#x6709;&#x5176;&#x5B83;&#x884C;&#x4E3A;&#xFF0C;&#x4E0D;&#x4FEE;&#x6539;&#x5916;&#x90E8;&#x7684;&#x503C; ,&#x4E0D;&#x6539;&#x53D8; input&#x3002;

3&#x3001;&#x5F15;&#x7528;&#x900F;&#x660E;
&#x53EA;&#x4F9D;&#x8D56;&#x4E8E;&#x8F93;&#x5165;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x4EFB;&#x4F55;&#x65F6;&#x5019;&#x53EA;&#x8981;&#x53C2;&#x6570;&#x76F8;&#x540C;&#xFF0C;&#x5F15;&#x7528;&#x51FD;&#x6570;&#x6240;&#x5F97;&#x5230;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x603B;&#x662F;&#x76F8;&#x540C;&#x7684;&#x3002;

4&#x3001;&#x6613;&#x4E8E; &#x5E76;&#x53D1;&#x7F16;&#x7A0B;
&#x56E0;&#x4E3A;&#x5B83;&#x4E0D;&#x4FEE;&#x6539;&#x53D8;&#x91CF;&#xFF0C;&#x6240;&#x4EE5;&#x6839;&#x672C;&#x4E0D;&#x5B58;&#x5728;&quot;&#x9501;&quot;&#x7EBF;&#x7A0B;&#x7684;&#x95EE;&#x9898;&#x3002; 

&#x603B;&#x662F;&#x611F;&#x89C9; Java8&#x7684;&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;&#x6709;&#x70B9;&#x5947;&#x602A;&#x3002; 
&#x7F51;&#x4E0A;&#x5F88;&#x591A;&#x6587;&#x7AE0;&#x76F4;&#x63A5;&#x5C06; &#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;&#x8DDF; lambd &#x6216; &#x6D41;&#x5F0F; &#x5BF9;&#x5E94;&#x3002;&#x611F;&#x89C9;&#x4E0D;&#x592A;&#x5BF9;&#x3002;

&#x4EE5;&#x4E0B;&#x4E3E;&#x4F8B;&#x6765;&#x81EA; &#x962E;&#x4E00;&#x5CF0; &#x7684;&#x535A;&#x5BA2;
&#x73B0;&#x5728;&#x6709;&#x8FD9;&#x6837;&#x4E00;&#x4E2A;&#x6570;&#x5B66;&#x8868;&#x8FBE;&#x5F0F; (1 + 2) * 3 - 4 &#xFF0C;
&#x4F20;&#x7EDF;&#x7684;&#x8FC7;&#x7A0B;&#x5F0F;&#x7F16;&#x7A0B;&#xFF0C;&#x53EF;&#x80FD;&#x8FD9;&#x6837;&#x5199;&#xFF1A;
var a = 1 + 2;
var b = a * 3;
var c = b - 4;
&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;&#x8981;&#x6C42;&#x4F7F;&#x7528;&#x51FD;&#x6570;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x628A;&#x8FD0;&#x7B97;&#x8FC7;&#x7A0B;&#x5B9A;&#x4E49;&#x4E3A;&#x4E0D;&#x540C;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x7136;&#x540E;&#x5199;&#x6210;&#x4E0B;&#x9762;&#x8FD9;&#x6837;
var result = subtract( multiply( add(1,2) , 3), 4);
</code></pre>
<h2 id="&#x4E3A;&#x4EC0;&#x4E48;-&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;-&#x53C8;&#x88AB;&#x5927;&#x91CF;&#x91C7;&#x7528;&#x548C;&#x652F;&#x6301;"><a name="&#x4E3A;&#x4EC0;&#x4E48;-&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;-&#x53C8;&#x88AB;&#x5927;&#x91CF;&#x91C7;&#x7528;&#x548C;&#x652F;&#x6301;" class="anchor-navigation-ex-anchor" href="#&#x4E3A;&#x4EC0;&#x4E48;-&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B;-&#x53C8;&#x88AB;&#x5927;&#x91CF;&#x91C7;&#x7528;&#x548C;&#x652F;&#x6301;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. &#x4E3A;&#x4EC0;&#x4E48; &#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B; &#x53C8;&#x88AB;&#x5927;&#x91CF;&#x91C7;&#x7528;&#x548C;&#x652F;&#x6301;</h2>
<p>c++ 11 &#x3001;Java8 &#x90FD;&#x7EB7;&#x7EB7;&#x52A0;&#x5165;&#x652F;&#x6301;</p>
<pre><code class="lang-text">1&#x3001;&#x7CBE;&#x7B80;&#x4EE3;&#x7801;&#xFF0C;&#x53BB;&#x6389;&#x5197;&#x4F59;&#x7684;&#x6A21;&#x677F;&#x4EE3;&#x7801;

2&#x3001;&#x51FD;&#x6570;&#x5F0F;&#x7F16;&#x7A0B; &#x5929;&#x751F;&#x7684; &#x53EF;&#x4EE5;&#x5E76;&#x884C;&#x7279;&#x6027; &#x3002;
&#x73B0;&#x5728; cpu &#x548C; &#x5185;&#x5B58; &#x8D8A;&#x6765;&#x8D8A;&#x591F;&#x7528; &#xFF0C;
&#x5BF9;&#x4E8E;&#x8D8A;&#x6765;&#x8D8A;&#x5E9E;&#x5927;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x4E0E;&#x5176; &#x8D39;&#x5927;&#x529B;&#x6C14;&#x53BB; &#x89E3;&#x51B3; &#x5404;&#x79CD;&#x9501;&#x548C;&#x540C;&#x6B65;&#x95EE;&#x9898;&#xFF0C;
&#x4E0D;&#x5982;&#x76F4;&#x63A5;&#x6539;&#x7528;&#x6839;&#x672C;&#x4E0D;&#x4F1A;&#x5BFC;&#x81F4;&#x8FD9;&#x4E9B;&#x95EE;&#x9898;&#x7684; FP &#x65B9;&#x6848; &#x3002;
</code></pre>
<h2 id="&#x533F;&#x540D;&#x51FD;&#x6570;"><a name="&#x533F;&#x540D;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x533F;&#x540D;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. &#x533F;&#x540D;&#x51FD;&#x6570;</h2>
<p>&#x53C2;&#x8003;&#x533F;&#x540D;&#x7C7B;&#x3002; &#x533F;&#x540D;&#x51FD;&#x6570;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x6CA1;&#x6709;&#x540D;&#x5B57;&#x7684;&#x51FD;&#x6570;&#x3002;
&#x5E38;&#x4E0E; Lambda &#x642D;&#x914D;&#x4F7F;&#x7528;</p>
<pre><code class="lang-text">// &#x65B0;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;Runnable &#x5BF9;&#x8C61;&#x3002;&#x7701;&#x7565;&#x4E86; Runnable &#x7684;run&#x51FD;&#x6570;&#x7684;&#x540D;&#x5B57;.
Runnable r = () -&gt; System.out.println(&quot;Thread start...&quot;);
new Thread(r).start();
</code></pre>
<h2 id="optional"><a name="optional" class="anchor-navigation-ex-anchor" href="#optional"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. Optional</h2>
<p>&#x662F;&#x4E00;&#x4E2A;&#x5C01;&#x88C5;&#x4E86;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7684;&#x5BB9;&#x5668;&#xFF0C;&#x800C;&#x8FD9;&#x4E2A;&#x5143;&#x7D20;&#x53EF;&#x4EE5;&#x662F;null&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x5176;&#x5B83;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x7684;&#x3002;</p>
<table>
<thead>
<tr>
<th>Optional &#x7684;&#x65B9;&#x6CD5;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>Optional.of(T t)</td>
<td>&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Optional &#x5B9E;&#x4F8B;</td>
</tr>
<tr>
<td> Optional.ofNullable(T t)</td>
<td>&#x82E5; t &#x4E0D;&#x4E3A; null,&#x521B;&#x5EFA; Optional &#x5B9E;&#x4F8B;,&#x5426;&#x5219;&#x521B;&#x5EFA;&#x7A7A;&#x5B9E;&#x4F8B;</td>
</tr>
<tr>
<td>Optional.empty()</td>
<td>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x7A7A;&#x7684; Optional &#x5B9E;&#x4F8B;</td>
</tr>
<tr>
<td>optional.get()</td>
<td>&#x83B7;&#x53D6;Optional&#x4E2D;&#x7684;&#x503C;</td>
</tr>
<tr>
<td>optional.isPresent()</td>
<td>&#x5224;&#x65AD;optional&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x6709;&#x503C;</td>
</tr>
</tbody>
</table>
<h2 id="stream"><a name="stream" class="anchor-navigation-ex-anchor" href="#stream"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. Stream</h2>
<pre><code class="lang-text">&#x8FD9;&#x4E2A; Stream &#x5E76;&#x4E0D;&#x662F;&#x6211;&#x4EEC;&#x4EE5;&#x524D;&#x8BA4;&#x8BC6;&#x7684;IO&#x6D41;&#xFF0C;
&#x800C;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x6E20;&#x9053;&#xFF0C;&#x7528;&#x4E8E;&#x64CD;&#x4F5C;&#x6570;&#x636E;&#x6E90;&#xFF08;&#x96C6;&#x5408;&#x3001;&#x6570;&#x7EC4;&#x7B49;&#xFF09;&#x6240;&#x751F;&#x6210;&#x7684;&#x5143;&#x7D20;&#x5E8F;&#x5217;&#x3002;
Stream API &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x79CD;&#x9AD8;&#x6548;&#x4E14;&#x6613;&#x4E8E;&#x4F7F;&#x7528;&#x7684;&#x5904;&#x7406;&#x6570;&#x636E;&#x7684;&#x65B9;&#x5F0F; &#xFF0C;&#x4F8B;&#x5982; &#x975E;&#x5E38;&#x590D;&#x6742;&#x7684;&#x67E5;&#x627E;&#x3001;&#x8FC7;&#x6EE4;&#x548C;&#x6620;&#x5C04;&#x6570;&#x636E;&#x7B49; &#x3002;
Stream &#x4E0D;&#x4F1A;&#x6539;&#x53D8;&#x6E90;&#x5BF9;&#x8C61;&#x3002;&#x5B83;&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x6301;&#x6709;&#x7ED3;&#x679C;&#x7684;&#x65B0;Stream&#xFF08;&#x8FD9;&#x6837;&#x53EF;&#x4EE5;&#x94FE;&#x5F0F;&#x7F16;&#x7A0B;&#xFF09;&#x3002;
</code></pre>
<h2 id="stream-&#x5EF6;&#x8FDF;&#x6267;&#x884C;"><a name="stream-&#x5EF6;&#x8FDF;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#stream-&#x5EF6;&#x8FDF;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9. Stream &#x5EF6;&#x8FDF;&#x6267;&#x884C;</h2>
<p>&#x53EA;&#x8981;Stream&#x7684;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x7684;&#x5BF9;&#x8C61;&#x662F;Stream&#xFF0C;&#x8FD9;&#x4E9B;&#x65B9;&#x6CD5;&#x5C31;&#x662F;&#x5EF6;&#x8FDF;&#x6267;&#x884C;&#x7684;&#x65B9;&#x6CD5; &#x3002;
&#x4E00;&#x822C;&#x5728;Stream&#x6D41;&#x4E2D;&#xFF0C;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x7684;&#x4E0D;&#x662F;Stream&#xFF0C;&#x57FA;&#x672C;&#x5C31;&#x662F; &#x8FEB;&#x5207;&#x65B9;&#x6CD5; &#x3002;</p>
<pre><code class="lang-text">// &#x7531;&#x96C6;&#x5408;&#x521B;&#x5EFA; Stream
List&lt;String&gt; list = new ArrayList&lt;&gt;();
//&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x987A;&#x5E8F;&#x6D41;
Stream&lt;String&gt; stream = list.stream();
//&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x5E76;&#x884C;&#x6D41;
Stream&lt;String&gt; parallelStream = list.parallelStream();

// &#x7531;&#x6570;&#x7EC4;&#x521B;&#x5EFA;&#x6D41;
Integer[] nums = new Integer[8];
Stream&lt;Integer&gt; stream3 = Arrays.stream(nums);

// &#x7531;&#x503C;&#x521B;&#x5EFA;&#x6D41;
Stream&lt;Integer&gt; stream4 = Stream.of(1,2,3,4,5);

// &#x7531;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x6D41; , &#x4F1A;&#x4E0D;&#x505C;&#x6253;&#x5370;&#x4E00;&#x4E2A;&#x968F;&#x673A;&#x6570;
Stream.generate(() -&gt; Math.random()).forEach(System.out::println);
Stream.iterate(1, (x) -&gt; x + 1).forEach(System.out::println);

// &#x7B5B;&#x9009; ,&#x81EA;&#x5B9A;&#x4E49;
List&lt;Integer&gt; list2 = Arrays.asList(2, 3, 5, 4, 4,4, 1, 8, 10, 9, 7, 6);
list2.stream() .filter((e) -&gt; e &gt; 5).forEach(System.out::println);
//  &#x7B5B;&#x9009; &#xFF0C;&#x53BB;&#x91CD;
list2.stream()  .distinct()  .forEach(System.out::println);
// &#x5207;&#x5272; &#xFF0C;&#x9650;&#x5B9A;&#x4E2A;&#x6570;
list2.stream().limit(3).forEach(System.out::println);
// &#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x53BB;&#x6389;&#x4E86;&#x524D; n &#x4E2A;&#x5143;&#x7D20;&#x7684;&#x6D41;&#x3002;&#x82E5;&#x5143;&#x7D20;&#x4E0D;&#x8DB3; n &#x4E2A;&#xFF0C;&#x5219;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7A7A;&#x6D41;&#x3002;
list.stream().skip(3).forEach(System.out::println);
// &#x6620;&#x5C04; , &#x5C06; &#x53C2;&#x6570; &#x7ECF;&#x8FC7;&#x81EA;&#x5B9A;&#x4E49;&#x5904;&#x7406;&#x540E; &#x518D;&#x8FD4;&#x56DE;
list2.stream() .map(x -&gt; x*x) .forEach(System.out::println);
// &#x7279;&#x6B8A;&#x7684; &#x6620;&#x5C04;&#x64CD;&#x4F5C; &#xFF0C; &#x7ED3;&#x679C;&#x4E00;&#x5B9A;&#x8981;&#x662F; double&#x7C7B;&#x578B;
list2.stream() .mapToDouble(x -&gt; x+0.1)  .forEach(System.out::println);

// &#x7279;&#x6B8A;&#x7684;&#x6620;&#x5C04; &#xFF0C; &#x5C06;&#x6D41;&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x6620;&#x5C04;&#x6210;&#x4E00;&#x4E2A;&#x6D41;
list2.stream()  .flatMap( xxx ) .forEach(System.out::println);

// &#x6309;&#x81EA;&#x7136;&#x987A;&#x5E8F;&#x6392;&#x5E8F;
list2.stream()   .sorted()  .forEach(System.out::println);
// &#x81EA;&#x5B9A;&#x4E49;&#x6392;&#x5E8F;
list.stream()  .sorted( (x,y) -&gt; -x.compareTo(y) )  .forEach(System.out::println);

// &#x68C0;&#x67E5;&#x662F;&#x5426;&#x5339;&#x914D;&#x6240;&#x6709;&#x5143;&#x7D20; ,(&#x662F;&#x5426;&#x5168;&#x90E8;&#x5143;&#x7D20;&#x90FD;&#x5927;&#x4E8E;2)
boolean allMatch = list2.stream() .allMatch(x -&gt; x &gt; 2);

// &#x5339;&#x914D;&#x5143;&#x7D20;&#x4F4D;&#x7F6E;
Optional&lt;Integer&gt; first = list2.stream() .findFirst();
int val = first.get();

// &#x6C42;&#x6700;&#x5927;&#x503C; &#x6700;&#x5C0F;&#x503C;
Optional&lt;Integer&gt; first1 = list2.stream() .min(Integer::compareTo);
Optional&lt;Integer&gt; first2 = list2.stream() .max(Integer::compareTo);
Integer val1 = first.get();

// &#x5C06;&#x6D41;&#x4E2D;&#x5143;&#x7D20;&#x6536;&#x96C6;&#x5230;List&#x4E2D;
List&lt;Integer&gt; resultList = list2.stream() .collect(Collectors.toList());
// &#x5C06;&#x6D41;&#x4E2D;&#x5143;&#x7D20;&#x6536;&#x96C6;&#x5230;Set&#x4E2D;
Set&lt;Integer&gt; resultSet = list2.stream() .collect(Collectors.toSet());
</code></pre>
<h2 id="&#x65E5;&#x671F;&#x65F6;&#x95F4;-api"><a name="&#x65E5;&#x671F;&#x65F6;&#x95F4;-api" class="anchor-navigation-ex-anchor" href="#&#x65E5;&#x671F;&#x65F6;&#x95F4;-api"><i class="fa fa-link" aria-hidden="true"></i></a>1.10. &#x65E5;&#x671F;&#x65F6;&#x95F4; API</h2>
<pre><code class="lang-text">&#x5728;&#x65E7;&#x7248;&#x7684; Java &#x4E2D;&#xFF0C;&#x65E5;&#x671F;&#x65F6;&#x95F4; API &#x5B58;&#x5728;&#x5F88;&#x591A;&#x95EE;&#x9898;&#xFF0C;&#x6BD4;&#x5982;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x95EE;&#x9898; &#x3001;&#x547D;&#x540D;&#x3001;&#x8BBE;&#x8BA1;&#x3001;&#x5206;&#x5305;&#x4E0D;&#x5408;&#x7406;&#x7B49;&#x95EE;&#x9898;&#x3002;
Java 8 &#x63D0;&#x4F9B;&#x7684;&#x65E5;&#x671F;&#x65F6;&#x95F4; API&#x90FD;&#x5728;java.time&#x5305;&#x4E0B;&#xFF0C;
&#x8FD9;&#x4E2A;&#x5305;&#x6DB5;&#x76D6;&#x4E86;&#x6240;&#x6709;&#x5904;&#x7406;&#x65E5;&#x671F;(date)&#xFF0C;&#x65F6;&#x95F4;(time)&#xFF0C;&#x65E5;&#x671F;/&#x65F6;&#x95F4;(datetime)&#xFF0C;
&#x65F6;&#x533A;&#xFF08;zone)&#xFF0C;&#x65F6;&#x523B;&#xFF08;instant&#xFF09;&#xFF0C;&#x95F4;&#x9694;&#xFF08;duration&#xFF09;&#x4E0E;&#x65F6;&#x949F;&#xFF08;clock&#xFF09;&#x7684;&#x64CD;&#x4F5C;

// &#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65E5;&#x671F;&#x65F6;&#x95F4;
LocalDateTime now = LocalDateTime.now();
int year = now.getYear();
int month = now.getMonthValue() ;
int day = now.getDayOfMonth() ;
// &#x5C06;&#x5F53;&#x524D;&#x65E5;&#x671F;&#x65F6;&#x95F4;&#x51CF;&#x53BB;&#x4E24;&#x5929;
LocalDateTime dateTime2 = now.minusDays(2);
// &#x5C06;&#x5F53;&#x524D;&#x65E5;&#x671F;&#x65F6;&#x95F4;&#x52A0;&#x4E0A;&#x4E94;&#x5929;
LocalDateTime dateTime3 = now.plusDays(5);
// &#x6784;&#x9020;&#x4E00;&#x4E2A;&#x6307;&#x5B9A;&#x65E5;&#x671F;&#x65F6;&#x95F4;&#x7684;&#x5BF9;&#x8C61; , &#x5E74; &#x6708; &#x65E5; &#x65F6; &#x5206;
LocalDateTime dateTime = LocalDateTime.of(2016, 10, 23, 8, 20);

// &#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65F6;&#x95F4;&#x7684;&#x65F6;&#x95F4;&#x6233;
Instant instant = Instant.now();
// &#x7ED3;&#x679C;&#x8DDF;System.currentTimeMillis()&#x4E00;&#x6837;
long milli = instant.toEpochMilli();
// &#x65F6;&#x533A;&#x504F;&#x79FB;
OffsetDateTime dateTime4 = instant.atOffset(ZoneOffset.ofHours(8));

//&#x65F6;&#x95F4;&#x95F4;&#x9694;
LocalTime start = LocalTime.now();
LocalTime end = LocalTime.now();
Duration duration = Duration.between(start, end);

// &#x65E5;&#x671F;&#x95F4;&#x9694;
LocalDate startDate = LocalDate.of(2015, 3, 4);
LocalDate endDate = LocalDate.of(2017, 8, 23);
Period period = Period.between(startDate, endDate);

// &#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5316; &#x4E3A;&#x5B57;&#x7B26;&#x4E32;  &#xFF0C; &#x5185;&#x7F6E;&#x683C;&#x5F0F;
LocalDate now6 = LocalDate.now();
String strNow = now6.format(DateTimeFormatter.BASIC_ISO_DATE);
// &#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5316; &#x4E3A;&#x5B57;&#x7B26;&#x4E32;  &#xFF0C; &#x81EA;&#x5B9A;&#x4E49;&#x683C;&#x5F0F;
String strNow2 = now6.format(DateTimeFormatter.ofPattern(&quot;yyyy&#x5E74;MM&#x6708;dd&#x65E5;&quot;));
// &#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x6210;&#x65E5;&#x671F;
LocalDate date = LocalDate.parse(strNow2, DateTimeFormatter.ofPattern(&quot;yyyy&#x5E74;MM&#x6708;dd&#x65E5;&quot;));

// &#x76EE;&#x524D;&#x652F;&#x6301;&#x7684;&#x65F6;&#x533A;
Set&lt;String&gt; set = ZoneId.getAvailableZoneIds();
//&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65F6;&#x533A;&#x7684;&#x65E5;&#x671F;&#x65F6;&#x95F4;
ZonedDateTime now3 = ZonedDateTime.now();
//&#x83B7;&#x53D6;&#x7F8E;&#x56FD;&#x6D1B;&#x6749;&#x77F6;&#x65F6;&#x533A;&#x7684;&#x65E5;&#x671F;&#x65F6;&#x95F4;
ZonedDateTime USANow = ZonedDateTime.now(ZoneId.of(&quot;America/Los_Angeles&quot;));
</code></pre>
<h2 id="&#x91CD;&#x590D;&#x6CE8;&#x89E3;"><a name="&#x91CD;&#x590D;&#x6CE8;&#x89E3;" class="anchor-navigation-ex-anchor" href="#&#x91CD;&#x590D;&#x6CE8;&#x89E3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.11. &#x91CD;&#x590D;&#x6CE8;&#x89E3;</h2>
<pre><code class="lang-text">&#x5728; java8 &#x4EE5;&#x524D;&#xFF0C;&#x540C;&#x4E00;&#x4E2A;&#x7A0B;&#x5E8F;&#x5143;&#x7D20;&#x524D;&#x6700;&#x591A;&#x53EA;&#x80FD;&#x6709;&#x4E00;&#x4E2A;&#x76F8;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x6CE8;&#x89E3;&#xFF1B;
&#x5982;&#x679C;&#x9700;&#x8981;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x524D;&#x4F7F;&#x7528;&#x591A;&#x4E2A;&#x76F8;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x6CE8;&#x89E3;&#xFF0C;&#x5219;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x6CE8;&#x89E3;&#x201C;&#x5BB9;&#x5668;&#x201D;&#x3002;
java8&#x7B80;&#x5316;&#x4E86;&#x4F7F;&#x7528;&#x7684;&#x6B65;&#x9AA4;&#xFF0C;&#x867D;&#x7136;&#x4ECD;&#x7136;&#x8981;&#x5B9A;&#x4E49;&#x201C;&#x5BB9;&#x5668;&#x201D; &#x3002;&#x4F46;&#x662F;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x7684;&#x5C31;&#x662F;&#x6CE8;&#x89E3;&#x3002;

// java8 &#x4E4B;&#x524D;&#x7684;&#x5199;&#x6CD5;
@Retention(RetentionPolicy.RUNTIME)
public @interface Authority {
    String role();
}

@Retention(RetentionPolicy.RUNTIME)
public @interface Authorities {
    Authority[] value();
}

@Authorities({@Authority(role = &quot;Admin&quot;), @Authority(role = &quot;Manager&quot;)})
private void test( ) { ... }

// java8 &#x53CA;&#x4E4B;&#x540E;&#x7684;&#x5199;&#x6CD5;
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Authorities.class)
public @interface Authority {
   String role();
}

@Retention(RetentionPolicy.RUNTIME)
public @interface Authorities {
    Authority[] value();
}

@Authority( role = &quot;Admin&quot; )
@Authority( role = &quot;Manager&quot; )
private void test( ) { ... }
</code></pre>
<footer class="page-footer"><span class="copyright">( no Copyright&#xFF0C;enjoy youself ! ) all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">The file was updated at :
2022-04-04 10:49:02
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="数据解析.html" class="navigation navigation-prev " aria-label="Previous page: 数据解析">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../android基础/android零散知识.html" class="navigation navigation-next " aria-label="Next page: Android部分">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Java8新特性","level":"1.11.18","depth":2,"next":{"title":"Android部分","level":"1.12","depth":1,"path":"chinese/android基础/android零散知识.md","ref":"chinese/android基础/android零散知识.md","articles":[{"title":"基础控件使用","level":"1.12.1","depth":2,"path":"chinese/android基础/基础控件使用.md","ref":"chinese/android基础/基础控件使用.md","articles":[]},{"title":"Android零散知识","level":"1.12.2","depth":2,"path":"chinese/android基础/android零散知识.md","ref":"chinese/android基础/android零散知识.md","articles":[]},{"title":"Android坐标体系","level":"1.12.3","depth":2,"path":"chinese/android基础/android坐标体系.md","ref":"chinese/android基础/android坐标体系.md","articles":[]},{"title":"APP启动流程","level":"1.12.4","depth":2,"path":"chinese/android基础/APP的启动流程.md","ref":"chinese/android基础/APP的启动流程.md","articles":[]},{"title":"View加载流程","level":"1.12.5","depth":2,"path":"chinese/android基础/View加载流程.md","ref":"chinese/android基础/View加载流程.md","articles":[]},{"title":"事件分发机制","level":"1.12.6","depth":2,"path":"chinese/android基础/事件分发机制.md","ref":"chinese/android基础/事件分发机制.md","articles":[]},{"title":"控件绘制流程","level":"1.12.7","depth":2,"path":"chinese/android基础/控件绘制流程.md","ref":"chinese/android基础/控件绘制流程.md","articles":[]},{"title":"常用shape","level":"1.12.8","depth":2,"path":"chinese/android基础/常用shape.md","ref":"chinese/android基础/常用shape.md","articles":[]},{"title":"进程通信","level":"1.12.9","depth":2,"path":"chinese/android基础/进程通信.md","ref":"chinese/android基础/进程通信.md","articles":[]},{"title":"通信方式详解","level":"1.12.10","depth":2,"path":"chinese/通信方式/通信方式详解.md","ref":"chinese/通信方式/通信方式详解.md","articles":[]},{"title":"Binder详解","level":"1.12.11","depth":2,"path":"chinese/android基础/Binder详解.md","ref":"chinese/android基础/Binder详解.md","articles":[]},{"title":"Handle详解","level":"1.12.12","depth":2,"path":"chinese/android基础/Handler详解.md","ref":"chinese/android基础/Handler详解.md","articles":[]},{"title":"Fragment详解","level":"1.12.13","depth":2,"path":"chinese/android基础/Fragment详解.md","ref":"chinese/android基础/Fragment详解.md","articles":[]},{"title":"Activity详解","level":"1.12.14","depth":2,"path":"chinese/android基础/Activity详解.md","ref":"chinese/android基础/Activity详解.md","articles":[]},{"title":"BroadcastReceiver详解","level":"1.12.15","depth":2,"path":"chinese/android基础/BroadcastReceiver.md","ref":"chinese/android基础/BroadcastReceiver.md","articles":[]},{"title":"Service详解","level":"1.12.16","depth":2,"path":"chinese/android基础/Service服务.md","ref":"chinese/android基础/Service服务.md","articles":[]},{"title":"动画详解","level":"1.12.17","depth":2,"path":"chinese/android基础/动画详解.md","ref":"chinese/android基础/动画详解.md","articles":[]},{"title":"屏幕刷新机制","level":"1.12.18","depth":2,"path":"chinese/android基础/屏幕刷新机制.md","ref":"chinese/android基础/屏幕刷新机制.md","articles":[]},{"title":"屏幕适配","level":"1.12.19","depth":2,"path":"chinese/android基础/屏幕适配.md","ref":"chinese/android基础/屏幕适配.md","articles":[]},{"title":"图片加载详解","level":"1.12.20","depth":2,"path":"chinese/android基础/图片加载详解.md","ref":"chinese/android基础/图片加载详解.md","articles":[]},{"title":"WebView详解","level":"1.12.21","depth":2,"path":"chinese/android基础/WebView详解.md","ref":"chinese/android基础/WebView详解.md","articles":[]},{"title":"沉浸式","level":"1.12.22","depth":2,"path":"chinese/android基础/沉浸式.md","ref":"chinese/android基础/沉浸式.md","articles":[]},{"title":"相机模块","level":"1.12.23","depth":2,"path":"chinese/android基础/相机模块.md","ref":"chinese/android基础/相机模块.md","articles":[]},{"title":"地图模块","level":"1.12.24","depth":2,"path":"chinese/android基础/地图模块.md","ref":"chinese/android基础/地图模块.md","articles":[]},{"title":"Androidstudio插件开发","level":"1.12.25","depth":2,"path":"chinese/android基础/Androidstudio插件开发.md","ref":"chinese/android基础/Androidstudio插件开发.md","articles":[]},{"title":"Apk插件化开发","level":"1.12.26","depth":2,"path":"chinese/android基础/Apk插件化开发.md","ref":"chinese/android基础/Apk插件化开发.md","articles":[]},{"title":"App组件化开发","level":"1.12.27","depth":2,"path":"chinese/android基础/App组件化开发.md","ref":"chinese/android基础/App组件化开发.md","articles":[]},{"title":"sdk开发","level":"1.12.28","depth":2,"path":"chinese/android基础/sdk开发.md","ref":"chinese/android基础/sdk开发.md","articles":[]},{"title":"APP优化","level":"1.12.29","depth":2,"path":"chinese/android基础/APP优化.md","ref":"chinese/android基础/APP优化.md","articles":[]},{"title":"项目参数配置","level":"1.12.30","depth":2,"path":"chinese/android基础/项目参数配置.md","ref":"chinese/android基础/项目参数配置.md","articles":[]},{"title":"App发布","level":"1.12.31","depth":2,"path":"chinese/android基础/App发布.md","ref":"chinese/android基础/App发布.md","articles":[]},{"title":"Android外挂","level":"1.12.32","depth":2,"path":"chinese/android基础/Android外挂.md","ref":"chinese/android基础/Android外挂.md","articles":[]},{"title":"Android字节码插桩","level":"1.12.33","depth":2,"path":"chinese/android基础/Android字节码插桩.md","ref":"chinese/android基础/Android字节码插桩.md","articles":[]},{"title":"智能家居","level":"1.12.34","depth":2,"path":"chinese/android基础/智能家居.md","ref":"chinese/android基础/智能家居.md","articles":[]}]},"previous":{"title":"数据解析","level":"1.11.17","depth":2,"path":"chinese/java基础/数据解析.md","ref":"chinese/java基础/数据解析.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","local-video","splitter","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"( no Copyright，enjoy youself ! )","modify_label":"The file was updated at :","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/java基础/java8新特性.md","mtime":"2022-04-04T02:49:02.761Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-04-04T03:47:09.782Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

